/*
* 渐变动画
* 自定义route动画
* 更多路由动画直接看：
* https://github.com/ahyangnb/flutter-advanced-book/blob/master/docs/chapter2/route.md
* https://github.com/fluttercandies/nav_router/tree/master/lib/routers
*
* 也可以使用全局路由来管理:NavigatorKey
* https://github.com/ahyangnb/flutter-advanced-book/blob/master/docs/chapter2/my_route.md
* */
import 'package:flutter/material.dart';

class FadeRoute extends PageRouteBuilder {
  // 传过来的页面page
  final Widget page;
  final RouteSettings routeSettings;

  // 构造
  FadeRoute(this.page, this.routeSettings)
      : super(
          pageBuilder: (
            BuildContext context,
            Animation<double> animation,
            Animation<double> secondaryAnimation,
          ) =>
              page,
          transitionsBuilder: (
            BuildContext context,
            Animation<double> animation,
            Animation<double> secondaryAnimation,
            Widget child,
          ) =>
              FadeTransition(
            opacity: animation, // 透明度
            child: child, // 页面存放
          ),
          settings: routeSettings,
        );
}
